package aimis.util;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

//分页工具类
public class FyUtils<T> {
//    private static int currentPage;//当前第几页
//    private static int pageSize;//每页几条
//    private static int total;//总共多少条
    public static <T> List<T> getlist(List<T> list,int currentPage,int pageSize,int total)
    {
        int mol = total % pageSize;
        int x = total / pageSize;
        List<T> list1 = new ArrayList<>();
        if(x >= currentPage)
        {
            for(int i = (currentPage-1) * pageSize; i < currentPage*pageSize ; i++)
            {
                list1.add(list.get(i));
            }
            return list1;
        }
        else
        {
            for(int i = x * pageSize ; i < x * pageSize+mol; i++)
            {
                list1.add(list.get(i));
            }
            return list1;
        }
    }
}
